package com.golxen.framework.module;

import com.golxen.utils.LogUtil;

import java.util.ArrayList;
import java.util.List;

public class ModulePlugin {

    static ModulePlugin instance = null;

    public static void start() {
        if (instance != null) {
            return;
        }

        instance = new ModulePlugin();
    }

    public static boolean active() {
        return instance != null;
    }

    public static void registModule(Class<?> moduleCls) {
        if (moduleClsList.contains(moduleCls)) {
            LogUtil.COMMON.info("[ModulePlugin] regist module repeated ========================== {}", moduleCls.getName());
            return;
        }
        moduleClsList.add(moduleCls);
        LogUtil.COMMON.debug("[ModulePlugin] regist module {}", moduleCls.getName());
    }

    public static List<Class<?>> getModuleClsList() {
        return moduleClsList;
    }

    static final List<Class<?>> moduleClsList = new ArrayList<>();

}
